﻿using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace TS2MP4.Converters;

internal class SizeToFriendlySizeConverter : IValueConverter
{
    public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is long && targetType == typeof(string))
            return $"{Math.Round(System.Convert.ToDouble(value) / (1024 * 1024), 2)}MB";

        return DependencyProperty.UnsetValue;
    }

    public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}